package com.myprocessing.timer;

import java.util.List;

import processing.core.PApplet;

public class TimerManager {
	protected List<Timer> timers;
	protected PApplet pApplet;
	public PApplet getPApplet() {
		return pApplet;
	}
	public void setPApplet(PApplet applet) {
		pApplet = applet;
	}
	public void init() {
		for (Timer t: timers) {
			t.init();
			t.setPApplet(pApplet);
		}
	}
	public void update(long currentTime) {
		for (Timer t: timers) {
			if (t.isActive()) {
				t.update(currentTime);
			}
		}
	}
	public List<Timer> getTimers() {
		return timers;
	}
	public void setTimers(List<Timer> timers) {
		this.timers = timers;
	}
	public void addTimer(Timer t) {
		timers.add(t);
	}
	public void removeTimer(Timer t) {
		timers.remove(t);
	}
}
